<script>
    $(document).ready(function () {
        $('#select-empresa').click(function () {
            var e_empresa_id = {
                name: $('#select-empresa').val()
            };
            $.ajax({
                url: "<?= base_url('divisiones/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: e_empresa_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value="*">Todas</option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.d_division_id + '">' + val.d_nombre + '</option>';
                    });
                    $("#select-division option").remove();
                    $("#select-modulo option").remove();
                    $("#select-submodulo option").remove();
                    $("#select-division").append(sc);
                }
            });
        });
    });
    $(document).ready(function () {
        $('#select-division').click(function () {
            var d_division_id = {
                name: $('#select-division').val()
            };
            $.ajax({
                url: "<?= base_url('modulos/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: d_division_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value="*">Todas</option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.m_modulo_id + '">' + val.m_nombre + '</option>';
                    });

                    $("#select-modulo option").remove();
                    $("#select-submodulo option").remove();
                    $("#select-modulo").append(sc);
                }
            });
        });
    });
    $(document).ready(function () {
        $('#select-modulo').click(function () {
            var m_modulo_id = {
                name: $('#select-modulo').val()
            };
            $.ajax({
                url: "<?= base_url('submod/jsonlist') ?>",
                type: 'POST',
                dataType: 'json',
                data: m_modulo_id,
                success: function (msg) {
                    var sc = '';
                    sc += '<option value="*">Todas</option>';
                    $.each(msg, function (key, val) {
                        sc += '<option value="' + val.sm_sub_modulo_id + '">' + val.sm_nombre + '</option>';
                    });
                    $("#select-submodulo option").remove();
                    $("#select-submodulo").append(sc);
                }
            });
        });
    });

</script>
<!-- Content -->
<div id="content">
    <!-- Content wrapper -->
    <div class="wrapper">
        <!-- Page header -->
        <div class="page-header">
            <div class="page-title">
                <h5><?= $place ?></h5>
            </div>
        </div>
        <!-- /page header -->
        <form class="form-horizontal" action="<?= base_url('reportes/rabcr') ?>" method="post">
            <fieldset>
                <!-- Form components -->
                <div class="row-fluid">
                    <!-- Column -->
                    <div class="span6">
                        <!-- Selects, dropdowns -->
                        <div class="widget">
                            <div class="navbar"><div class="navbar-inner"><h6>Generar Reporte</h6></div></div>
                            <!-- Cuerpo de Inputs -->
                            <div class="well">
                                <!-- Selector Empresa-->
                                <div class="control-group">
                                    <label class="control-label">Empresa: </label>
                                    <div class="controls">
                                        <select multiple="multiple" class="multiple" id="select-empresa" name="empresa">
                                            <option value="*">Todas</option>      
                                            <?php foreach ($empresa as $e) { ?>
                                                <option value="<?= $e->e_empresa_id ?>"><?= $e->e_nombre ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                                <!-- /Selector Empresa -->
                                <!-- Selector Division-->
                                <div class="control-group">
                                    <label class="control-label">División: </label>
                                    <div class="controls">
                                        <select multiple="multiple" class="multiple" id="select-division" name="division">
                                            <option ></option>
                                        </select>
                                    </div>
                                </div>
                                <!-- /Selector Division -->
                                <!-- Selector Módulo-->
                                <div class="control-group">
                                    <label class="control-label">Módulo: </label>
                                    <div class="controls">
                                        <select multiple="multiple" class="multiple" id="select-modulo" name="modulo">
                                            <option ></option>
                                        </select>
                                    </div>
                                </div>
                                <!-- /Selector Módulo -->
                                <!-- Selector subMódulo-->
                                <div class="control-group">
                                    <label class="control-label">SubMódulo: </label>
                                    <div class="controls">
                                        <select multiple="multiple" class="multiple" id="select-submodulo" name="submodulo">
                                            <option ></option>
                                        </select>
                                    </div>
                                </div>
                                <!-- /Selector subMódulo -->


                                <!-- Botones -->
                                <div class="form-actions align-right">
                                    <button type="submit" class="btn btn-primary">Generar</button>
                                </div>
                                <!-- /Botones -->
                            </div>
                            <!-- /Cuerpo de Inputs -->
                        </div>
                        <!-- /Selects, dropdowns -->
                    </div>
                    <!-- /Columns -->
                </div>
                <!-- /Form Components -->
            </fieldset>
        </form>
        <!-- form -->
    </div>
    <!-- /content wrapper -->
</div>
<!-- /content -->
